Skip to content

feat(collector): support reading config file path from CLI and loading log configuration from config file in Go Collector#2375

Open
empiredan wants to merge 5 commits intoapache:masterfrom
empiredan:go-collector-config-log
Open

feat(collector): support reading config file path from CLI and loading log configuration from config file in Go Collector#2375
empiredan wants to merge 5 commits intoapache:masterfrom
empiredan:go-collector-config-log

Conversation

@empiredan
Copy link
Contributor

@empiredan empiredan commented Feb 25, 2026

#2358

This PR adds support for the Go collector to obtain the configuration file path
via command-line arguments.

It also makes log initialization configurable by loading log-related settings from
the configuration file, including the log file path, log level, log retention time, and
the number of retained log files.

@empiredan empiredan marked this pull request as ready for review February 25, 2026 09:52
Copy link

@acelyc111-bot acelyc111-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Configurable logging for Go Collector

Summary: Adds CLI flag -config for specifying config file path and moves all log configuration (filename, size, retention, level) into config.yml with proper validation and defaults.

What's good:

  • Clean refactoring: main() is now much more readable with loadConfigs() and setupLog() extracted
  • Proper validation for all config values with early os.Exit on errors
  • Sensible defaults: /tmp/collector.log, 64MB, 3 days, 8 files, info level
  • The -config flag makes deployment easier (was previously hardcoded as config.yml)
  • Error messages go to stderr before exit — good practice for CLI tools

Minor notes:

  • setupLog() is a bit long — the repeated pattern of get option → check ok → validate → set default could be extracted into a small helper like getConfigInt(options, key, default) to reduce boilerplate
  • The old code logged to ./pegasus.log but the new default is /tmp/collector.log — this is a behavioral change that should be noted in release notes (though /tmp is arguably a better default)

Verdict: ✅ Approve — Clean, well-validated config improvement. Ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants